<?php
/**
 * @Author: gan
 * @Description:
 * @File:  SmsBase
 * @Version: 1.0.0
 * @Date: 2021/12/27 9:19 上午
 */
declare(strict_types=1);

namespace RX\Component\Sms;

use RX\Component\Sms\Impl\AliyunImpl;
use RX\Component\Sms\Impl\JuheImpl;
use RX\Component\Sms\Impl\MwImpl;
use RX\Component\Sms\Impl\SmsInterface;
use RX\Component\Sms\Impl\TencentImpl;
use RX\Enums\CommonEnum;
use RX\Exception\BizException;

class SmsStaticFactory
{
    /**
     * @param string $type
     * @param array $config
     * @return SmsInterface
     * @throws BizException
     */
    public static function factory(string $type, array $config = []): SmsInterface
    {
        switch ($type) {
            case SmsType::ALIYUN:
                return new AliyunImpl($config);
            case SmsType::TENCENT:
                return new TencentImpl($config);
            case SmsType::JUHE:
                return new JuheImpl($config);
            case SmsType::MW:
                return new MwImpl($config);
            default:
                throw new BizException(CommonEnum::class, CommonEnum::INVALID_PARAMS);
        }
    }
}
